<%@ page language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Do Logout</title>
<%
	System.out.println("in dologout");
	session = request.getSession();
	session.invalidate();
	response.sendRedirect("login.jsp");
%>

<%-- Connection conn = null;
Class.forName("org.sqlite.JDBC");
conn = DriverManager.getConnection("jdbc:sqlite://Users/Annie/Documents/workspace/HomeFinders/homefinders.db");
ResultSet rsdoLogout = null;
Statement psdoLogout=null;
//ResultSet rsdb = null;
Statement psdb = null;
//String sUserID=session.getAttribute("username");
//String sPassword=request.getParameter("sPwd");
//System.out.println("input "+sUserID + sPassword);
String message="User login successfully ";
String sqlOption="update login set loggedin = 0 where username = '" +session.getAttribute("username")+"';";
System.out.println(sqlOption);
psdb = conn.createStatement();
//psdoLogout = conn.createStatement();

try{
	psdb.executeUpdate(sqlOption);
	//sqlOption="SELECT loggedin FROM login where username = '" +session.getAttribute("username")+"';";
	//psdoLogout = conn.createStatement();
	//rsdb=psdoLogout.executeQuery(sqlOption);
	//if(rsdb.next())
		//System.out.println(rsdb.getString("loggedin"));
	response.sendRedirect("login.jsp");
}
catch(Exception e)
{
    e.printStackTrace();
} %>

<script type="text/javascript">
<div id="myResults"></div>
if(typeof(Storage)!=="undefined")
{
  sessionStorage.currentuser = "null";
  sessionStorage.loggedin = 0;
}
</script>

<% try{
     if(psdb!=null){
    	 psdb.close();
     }
     if(conn!=null){
      conn.close();
     }
}
catch(Exception e)
{
    e.printStackTrace();
}

%> --%>
</head>
</html>